//
//  MHCategory.m
//  MiaoCircle
//
//  Created by 许正荣 on 2018/4/17.
//  Copyright © 2018年 acgera. All rights reserved.
//

#import "MHFontCategory.h"
#import "LFXRuntime.h"

@implementation MHFontCategory

@end


@implementation UIButton (MHFontTransfer)

+ (void)load{
    methodSwizThreadSafe(self, @selector(initWithCoder:), @selector(mh_InitWithCoder:));
}

- (id)mh_InitWithCoder:(NSCoder*)aDecode{
    [self mh_InitWithCoder:aDecode];
    if (self) {
        CGFloat fontSize = self.titleLabel.font.pointSize;
        self.titleLabel.font = UIFontFromPixel(fontSize);
    }
    return self;
}
@end

@implementation UILabel (MHFontTransfer)

+ (void)load{
    methodSwizThreadSafe(self, @selector(initWithCoder:), @selector(mh_InitWithCoder:));
}

- (id)mh_InitWithCoder:(NSCoder*)aDecode{
    [self mh_InitWithCoder:aDecode];
    if (self) {
        CGFloat fontSize = self.font.pointSize;
        self.font = UIFontFromPixel(fontSize);
    }
    return self;
}
@end

@implementation UITextField (MHFontTransfer)

+ (void)load{
    methodSwizThreadSafe(self, @selector(initWithCoder:), @selector(mh_InitWithCoder:));
}

- (id)mh_InitWithCoder:(NSCoder*)aDecode{
    [self mh_InitWithCoder:aDecode];
    if (self) {
        CGFloat fontSize = self.font.pointSize;
        self.font = UIFontFromPixel(fontSize);
    }
    return self;
}
@end

@implementation UITextView (MHFontTransfer)

+ (void)load{
    methodSwizThreadSafe(self, @selector(initWithCoder:), @selector(mh_InitWithCoder:));
}
- (id)mh_InitWithCoder:(NSCoder*)aDecode{
    [self mh_InitWithCoder:aDecode];
    if (self) {
        CGFloat fontSize = self.font.pointSize;
        self.font = UIFontFromPixel(fontSize);
    }
    return self;
}
@end



